package com.zan.pattern.visitor.extend.test3;

/**
 * @Author Zan
 * @Create 2024/4/27 20:10
 * @Description : TODO(请用一句话描述该类的功能)
 * @ClassName: Client3
 */
class Animal {
    public void accept(Execute exe) {
        exe.execute(this);
    }
}

class Dog extends Animal {
    public void accept(Execute exe) {
        exe.execute(this);
    }
}

class Cat extends Animal {
    public void accept(Execute exe) {
        exe.execute(this);
    }
}

class Execute {
    public void execute(Animal a) {
        System.out.println("animal");
    }

    public void execute(Dog d) {
        System.out.println("dog");
    }

    public void execute(Cat c) {
        System.out.println("cat");
    }
}

public class Client3 {
    public static void main(String[] args) {
        Animal a = new Animal();
        Animal d = new Dog();
        Animal c = new Cat();

        Execute exe = new Execute();
        a.accept(exe);
        d.accept(exe);
        c.accept(exe);
    }
}
